Anytime you use a function or subroutine, including a system function, you have two choices (for a subroutine) or three (for a function).*
For a function, you can use the function call syntax FuncName(arg1, arg2). But to use the function call syntax, you must do something with the return value. E.g: result = FuncName(arg1, arg2) or Print FuncName(arg1, arg2).
For a subroutine or a function, you can use the statement syntax (discarding the return value, if it's a function). E.g.:
- SubOrFuncName arg1, arg2
- Call SubOrFuncName(arg1, arg2)
You can legally use Call and include parens, or leave off Call and also leave off the parens. You can't leave off Call and still use parens, as you were trying to do.
Some people get confused about this because if a subroutine or function has one argument, in many cases you can use the statement syntax and include parens, e.g.:
- SubOrFuncName(x)
In this case, strange as it may seem, the parenthesis are considered not to enclose the list of arguments, but only the first argument -- there just happens to be only one. These parens actually have a functional meaning -- they force the argument to be passed by value -- the subroutine is given a copy, so that it can't alter the original value.† The equivalent Call syntax would be:
- Call SubOrFuncName((x))
Or if there are multiple arguments, you might write something like this:
- SubOrFuncName x, (y), z
But you can't write:
- SubOrFuncName(x, y) ' wrong!
- a = (x, y)
In the statement syntax, parens are expected to enclose an expression, not a list of parameters. So when the parser sees a comma after x, it gets confused. In an expression, you can't use a comma right after a variable name or constant -- the parser was expecting to see either an operator (e.g. "+") or the close paren. Does that make the error message clearer?
* If I don't mention it, some picky person will probably point out that for many system functions you can only use the function syntax. Messagebox is not one of these.
† Not all types of variables can be treated in this way, so depending on how x is declared, in some cases this syntax may still be illegal.